*Table 4
*delete next line
cd "C:\Users\Martin Steinwand\Documents\Project Maritime Boundaries\Data\R&RJCR"
*uncomment next line, update your path
*cd "<Your replication directory>"
*Do row 1 first
clear
use "Boundary Data_work.8-22-15.dta"
gen oilind=0
replace oilind=1 if oildisa==1 & oildisb==0
replace oilind=1 if oildisa==0 & oildisb==1
replace oilind=3 if oildisa==1 & oildisb==1
label variable oilind "indicator, no oil, one-sided, two-sided"

bysort id2: egen anyagree=max(agreement)
by id2: egen anyoilind=max(oilind)
*only keep country level data
duplicates drop id2, force 

*row 1: percentage of countries that agree, by oil status
tabulate anyagree anyoilind, column

clear
use "OutcomesData.9-20-15.R&R.dta"

* need to create variable for cases of one-sided
* oil discovery that captures share of oil producer

gen share_oil_single = .
replace share_oil_single=shareal if oildisa==1 & oildisb==0
replace share_oil_single=sharebl if oildisa==0 & oildisb==1
label variable share_oil_single "share of states with single oil discovery"

*now regularize the share variable for two-sided oil discovery,
    *ensuring that the larger split get's counted for each
    *observation

gen share_oil_both = .
replace share_oil_both = shareal if shareal >= sharebl & (oildisa==1 & oildisb==1)
replace share_oil_both = sharebl if sharebl >= shareal & (oildisa==1 & oildisb==1)
label variable share_oil_both "split if both states have oil (greater .5)"

*now regularize the share variable if there is no oil,
    *ensuring that the larger split get's counted for each
    *observation

gen share_no_oil = .
replace share_no_oil = shareal if shareal >= sharebl & (oildisa==0 & oildisb==0)
replace share_no_oil = sharebl if sharebl >= shareal & (oildisa==0 & oildisb==0)
label variable share_no_oil "split if neither state has oil (greater .5)"

*indicator variable for oil
gen oilind =.
replace oilind = 0 if oildisa==0 & oildisb==0
replace oilind = 1 if (oildisa==1 & oildisb==0) | (oildisa==0 & oildisb==1)
replace oilind = 2 if oildisa==1 & oildisb==1
label variable oilind "indicator, no oil, one-sided, two-sided"

*recode difshare
gen difshare_a = -(difshare-100)
label variable difshare_a "-(difshare-100)"

*Rows 2 and 3 in table 4
tabulate oilind, summarize(difshare_a)
sum share_no_oil share_oil_single share_oil_both
